package cn.edu.hit.kg.entity;

//import org.neo4j.driver.v1.types.Node;

import cn.edu.hit.kg.data.Node;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;

public interface ISignalMatch {
    boolean matchSignal(List<Signal> signals, long timestamp, String unitId);

    MatchResultType matchByConclusions(Map<Long,Boolean> conclusions);
    MatchTrack trackByConclusions(Map<Long,Boolean> conclusions);

    List<Integer> getOutIds();

    boolean isMatched();

    boolean isUnKnown();

    long getId();

    static ISignalMatch fromNode(Node node) {
        if (node.hasLabel("Feature")) {
            return new Feature(node);
        } else if (node.hasLabel("FeatureGroup")) {
            return new FeatureGroup(node);
        } else {
            return new Fault(node);
        }
    }

    /**
     * 返回 List of 子节点 where outId != 0
     *
     * @return List of 子节点 where outId != 0 and 子节点.isMatched()
     */
    List<ISignalMatch> getOutMatches();

    List<Long> getSubMatched();

    List<Long> getSubUnknown();

    HashSet<String> getChannelIds(String unitId);

    Set<Feature> getFeatureSet();

    Predicate<ISignalMatch> isUnknown = ISignalMatch::isUnKnown;
    Predicate<ISignalMatch> isMatched = ISignalMatch::isMatched;
    Predicate<ISignalMatch> onlyUnknown = isUnknown.and(isMatched.negate());

    enum MatchResultType{
        TRUE,FALSE,UNKNOWN,SKIP
    }
}
